package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.ServiceInvDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity ServiceInv and its DTO ServiceInvDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, })
public interface ServiceInvMapper extends EntityMapper <ServiceInvDTO, ServiceInv> {

    @Mapping(source = "product.id", target = "productId")
    ServiceInvDTO toDto(ServiceInv serviceInv); 

    @Mapping(source = "productId", target = "product")
    ServiceInv toEntity(ServiceInvDTO serviceInvDTO); 
    default ServiceInv fromId(Long id) {
        if (id == null) {
            return null;
        }
        ServiceInv serviceInv = new ServiceInv();
        serviceInv.setId(id);
        return serviceInv;
    }
}
